lobsterlayui.main(['index', 'layer', 'form', 'element', 'table'], {
    data: {
        $layui: null,
    },
    pageload: function (right) {
        console.log(right);
        this.initevent();
        this.TableLoad();
    },
    initevent() {
        var self = this;
        //搜索
        layui.form.on("submit(LAY-search)", function (data) {
            self.data.tableins.reload({
                where: {
                    drugName: $("#pdrugName").val(),
                },
                page: {
                    curr: 1
                }
            });
        });
    },
    //中药材表格加载
    TableLoad() {
        var self = this;

        var drugNamestr = $("#pdrugName").val();

        self.data.tableins = layui.table.render({
            elem: "#entlist",
            headers: lobsterlayui.GetHeaderData(),
            where: {
                drugName: drugNamestr,
            },
            url: lobsterlayui.GetLowCodeUrl('tscnmedmaterial.getMedMaterialdata'),
            defaultToolbar: [],
            size: '10',
            height: 'full-130',
            page: true, //开启分页
            loading: true,
            cols: [
                [
                    { field: '药材名称', title: '药材名称', width: '8%' },
                    { field: '药材别名', title: '药材别名', width: '12%' },
                    { field: '药材基原', title: '药材基原', width: '20%' },
                    { field: '性味归经', title: '性味归经', width: '10%' },
                    { field: '功能主治', title: '功能主治', width: '20%' },
                    { field: '注意事项', title: '注意事项', width: '20%' },
                    { field: '主要药用类别', title: '主要药用类别', width: '10%' },
                    { field: '标准来源', title: '标准来源', width: '10%' },
                    { field: '页码', title: '页码', width: '5%' }
                ]
            ],
            done: function (res, curr, count) {
                $(".layui-table-main tr").each(function (index, val) {
                    $($(".layui-table-fixed-l .layui-table-body tbody tr")[index]).height($(val).height());
                    $($(".layui-table-fixed-r .layui-table-body tbody tr")[index]).height($(val).height());
                })
            },
            parseData: function (res) {
                return {
                    code: res.code,
                    msg: res.msg,
                    count: res.data.count,
                    data: res.data.list
                }
            }
        });
    }

})